Skip to main content

Inputs and Outputs API

In this section we will see examples to get details about inputs and outputs of a transaction from Bitcoin network.

Get the Bitcoin Price on a Given date

THis query returns price of the Bitcoin on a given date. For this example the date is 2016-01-01.

query MyQuery {
bitcoin {
outputs(date: {is: "2016-01-01"}) {
value
usd: value(in: USD)
expression(get: "usd/value")
}
}
}

Get Bitcoin Balance on a given height

Below query gives you balance of a bitcoin address at a specific Block height. Run here.

{
bitcoin(network: bitcoin) {
inputs(
height: {lteq: 919195}
inputAddress: {is: "bc1ppu6akjngyvpxwz0w38n4evcygwh08tjtmcc0dx6ft2zzgkxtd97stwehcq"}
) {
count
value
value_usd: value(in: USD)
min_date: minimum(of: date)
max_date: maximum(of: date)
}
outputs(
height: {lteq: 919195}
outputAddress: {is: "bc1ppu6akjngyvpxwz0w38n4evcygwh08tjtmcc0dx6ft2zzgkxtd97stwehcq"}
) {
count
value
value_usd: value(in: USD)
min_date: minimum(of: date)
max_date: maximum(of: date)
}
}
}

Get the UTXO Input and Outputs for a specific address

Run Query

{
bitcoin(network: bitcoin) {
spendvolumes: inputs(
inputAddress: {is: "bc1p4kufll9uhnpkgzuc65slcxd2qaw2hl9xecket3h8yyu4awglcsqslqaztd"}
height: {between: [822372, 822376]}
) {
date {
date
}
any(of: amount)
block {
height
}
transaction {
hash
}
inputAddress {
annotation
address
}
value
}
recievevolumes: outputs(
height: {between: [822372, 822376]}
outputAddress: {is: "bc1p4kufll9uhnpkgzuc65slcxd2qaw2hl9xecket3h8yyu4awglcsqslqaztd"}
) {
date {
date
}
any(of: amount)
transaction {
hash
}
block {
height
}
outputAddress {
annotation
address
}
value
}
}
}


In this query we have used two of API sets named “inputs” and “outputs” for getting the spent and received bitcoin currency for the address “bc1p4kufll9uhnpkgzuc65slcxd2qaw2hl9xecket3h8yyu4awglcsqslqaztd” with filtering out by block height within a specific number range, and it provides the transaction hash, block height and amount.

Get Parsed Datum of a Cardano Transaction UTXO

This query fetches output data for a given transaction hash on the Cardano blockchain, which includes parsed datum (included in the properties field). You can run the query here

query ($network: CardanoNetwork!, $hash: String!, $limit: Int!, $offset: Int!) {
cardano(network: $network) {
outputs(
txHash: {is: $hash}
options: {asc: "outputIndex", limit: $limit, offset: $offset}
) {
outputIndex
address: outputAddress {
address
annotation
}
value
value_usd: value(in: USD)
currency {
symbol
tokenType
tokenId
properties
name
decimals
address
}
outputDirection
date {
date
}
transaction {
hash
}
valueDecimal
}
}
}
{
"limit": 10,
"offset": 0,
"network": "cardano",
"hash": "6c83cf62225ecdf0cbb57e11718a8ec079f490b7f05d97f5a6d2214fb00be182"
}

The properties field inside the currency object will contain parsed datum in YAML-like format:

"properties": "---\nassetName: 494e4459\nfingerprint: asset1u8caujpkc0km4vlwxnd8f954lxphrc8l55ef3j\npolicyId: 533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0\n",

Getting Miners Block Rewards per Day

query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
address: outputAddress {
address
annotation
}
date {
date(format: $dateFormat)
}
reward: value
count(uniq: blocks)
}
}
}

We can get the miner Block reward per day by using the outputs API and using the filters of outputDirection set to mining and we get parameters such as miner address, miner rewards in the whole day and blocks they mined. Yo can try running the example query here.

Get Miners Activity in a Specific Timeframe

This query returns the activity count of miners within a specific date range. You can run this query here.

query MyQuery {
bitcoin(network: bitcoin) {
outputs(
outputDirection: {is: mining}
date: {since: "2025-01-01", till: "2025-01-10"}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
outputAddress {
address
}
count
}
}
}

Get Miners First Activity

This query returns the first mining activity for specific miner addresses, showing when each miner first received a block reward. You can run this query here.

query MyQuery {
bitcoin(network: bitcoin) {
outputs(
outputDirection: {is: mining}
options: {asc: "block.timestamp.iso8601", limitBy: {each: "outputAddress.address", limit: 1}}
outputAddress: {in: ["1K6KoYC69NnafWJ7YgtrpwJxBLiijWqwa6", "1KGG9kvV5zXiqyQAMfY32sGt9eFLMmgpgX"]}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
outputAddress {
address
}
block {
timestamp {
iso8601
}
}
}
}
}

Video Tutorial to Get Daily Miner Rewards Info